import QtQuick
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects

Item {
    property alias iconSource: avatar.icon
    property alias nackName: nickname.text
    property alias latestMessage: latestmessage.text
    property alias unReadMessageCount :avatar.unreadn
    property alias timeStamp: timestamp.text
    property bool isMute: false

    id: root
    width: parent.width
    height: parent.height

    RowLayout {
        anchors.fill: parent
        Item {
            id: c1
            Layout.preferredWidth: 35
            Layout.preferredHeight: 35
            Layout.maximumWidth: 35
            Layout.maximumHeight: 35
            Layout.leftMargin: 10
            Avatar {
                id: avatar
                icon: 'qrc:/img/icon/me.jpg'
                size: 35
            }
        }

        Item {
            Layout.preferredWidth: 130
            Layout.preferredHeight: parent.height
            Layout.minimumWidth: 100
            Layout.maximumWidth: root.width - 125
            Layout.leftMargin: 3
            Layout.fillWidth: true
            Column {
                id: c2
                anchors.left:parent.left
                anchors.right: parent.right
                anchors.verticalCenter: parent.verticalCenter
                Text {
                    width: parent.width
                    id: nickname
                    text: nackName
                    font.pixelSize: 14
                    elide: Text.ElideRight
                }

                Text {
                    width: parent.width
                    id: latestmessage
                    font.pixelSize: 12
                    color: '#9f9f9f'
                }
            }
        }

        Item {
            width: 80
            height: parent.height
            Column {
                topPadding:20
                bottomPadding: 20
                Text {
                    width: 80
                    id: timestamp
                    text: timeStamp
                    color: '#9f9f9f'
                    font.pixelSize: 10
                }
                Image {
                    id: mute
                    source: isMute ? '' : ''
                }
            }
        }
    }

    MouseArea {
        onClicked: {
                    console.log("值:", modelData)
                    console.log("索引:", index)
                }
        onPressAndHold: {
            console.log("值:", onPressAndHold)
        }
    }
}
